package com.light.applet.oauth.controller;

import org.springframework.security.oauth2.common.exceptions.InvalidClientException;

import java.util.Map;

/**
 * @author: 魏彪
 */
public class AbstractOauth {

    protected void check(Map<String, String> parameters){
        if (!parameters.containsKey("clientId")){
            throw new InvalidClientException("client ID does not presents");
        }
    }

    protected boolean isRefreshTokenRequest(Map<String, String> parameters) {
        return "refresh_token".equals(parameters.get("grant_type")) && parameters.get("refresh_token") != null;
    }

    protected boolean isAuthCodeRequest(Map<String, String> parameters) {
        return "authorization_code".equals(parameters.get("grant_type")) && parameters.get("code") != null;
    }
}
